home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-13 | 2.9 KB | 96 lines | [TEXT/MPS ] |
- PROGRAM SpeakFile(f);
-
- (* A quick and dirty program to read a file out loud. The file must be named
- "TextToSpeak" and reside on the default drive. The program reads 5120
- characters from this file and sends that string thru the Reader English to
- phonetics converter. The output from Reader is then sent thru the MacinTalk
- speech synthesizer. The input file is assumed to be terminated by a "##".
- Only the SpeechOn error code is checked. THIS PROGRAM IS INTENDED ONLY AS A
- DEMONSTRATION OF HOW TO SETUP AND CALL THE SPEECH SYNTHESIZER, AND DOES
- NOT CONFIRM TO MACINTOSH'S USER INPUT STYLE.
-
- Here is a simple build procedure:
-
- pascal -p {MPW}SpeakFile.p
- link -p -c MBAU -t APPL ∂
- "{MPW}"SpeakFile.p.o ∂
- "{Libraries}"Interface.o ∂
- "{Libraries}"Runtime.o ∂
- "{PLibraries}"Paslib.o ∂
- "{Libraries}"SpeechIntf.o ∂
- -o SpeakFile
-
- This assumes:
- SpeakFile.p is in {MPW}
- SpeechIntf.p is in {PInterfaces}
- SpeechIntf.o is in {Libraries}
-
- *)
-
- USES
- {$LOAD PasDump.dump}
- Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf, SpeechIntf;
-
-
-
-
- TYPE
- bytes = packed array[1..5120] of char;
- byteptr = ^bytes;
-
-
- VAR
- i: INTEGER;
- linein: bytes; {the English text to be spoken}
- lineptr: byteptr; {a pointer to the text}
- f: file; {for input file TextToSpeak}
- output: Handle; {Handle to phonetic string}
- theSpeech: SpeechHandle; {Handle to speech globals}
-
-
- BEGIN
-
- i := SpeechOn('', theSpeech); {Open the speech driver and the
- READER English to phonetics
- conversion package with the default
- pronounciation ruleset.}
-
-
- IF (i <> 0) THEN exit(SpeakFile); {If error, go away}
-
-
- reset(f, 'TextToSpeak'); {Open the English input file.}
-
-
-
- i := blockread(f, linein, 10); {Read 10 blocks (5120 chars) from
- the input file.}
-
-
- lineptr := @linein; {Setup pointer to the English text.}
-
-
- output := NewHandle(0); {Create a handle for the phonetic
- output. Reader will dynamically
- grow this handle as needed.}
-
-
- {Convert the English text to phonetic codes.}
-
- i := Reader(theSpeech, POINTER(lineptr), 6000, output);
-
-
- i := MacinTalk(theSpeech, output); {Say it.}
-
-
- SpeechOff(theSpeech); {Close the speech driver.}
-
-
- DisposHandle(output); {Release the output handle}
-
-
- close(f) {Close the input file.}
-
- end.
-
-